package logic

import (
	"context"
	"week3/projectsrv/service"

	"week3/projectsrv/internal/svc"
	"week3/projectsrv/projectsrv"

	"github.com/zeromicro/go-zero/core/logx"
)

type SaveOrderStatusLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSaveOrderStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveOrderStatusLogic {
	return &SaveOrderStatusLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 修改订单状态
func (l *SaveOrderStatusLogic) SaveOrderStatus(in *projectsrv.SaveOrderStatusReq) (*projectsrv.SaveOrderStatusRes, error) {
	// todo: add your logic here and delete this line
	res, err := service.GetOrderByOrderSn(in.OrderSn)
	if err != nil {
		return nil, err
	}
	err = service.SaveOrder(res)
	if err != nil {
		return nil, err
	}
	return &projectsrv.SaveOrderStatusRes{}, nil
}
